package com.lottery.im.module.result.adapter.result.statistics;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.lottery.im.R;
import com.lottery.im.api.result.entity.LongStatisticsInfo;
import java.util.List;

public class LongStatisticsAdapter extends BaseAdapter {
  private List<LongStatisticsInfo> mDataList;
  private Context mContext;

  public LongStatisticsAdapter(Context context, List<LongStatisticsInfo> list) {
    mDataList = list;
    mContext = context;
  }

  @Override public int getCount() {
    return mDataList.size();
  }

  @Override public Object getItem(int position) {
    if (position >= mDataList.size() || position < 0) return null;
    return mDataList.get(position);
  }

  @Override public long getItemId(int position) {
    return position;
  }

  @SuppressLint("SetTextI18n") @Override
  public View getView(final int position, View v, ViewGroup parent) {
    final ViewHolder holder;
    if (v == null) {
      v = LayoutInflater.from(mContext).inflate(R.layout.item_statistics_list, parent, false);
      holder = new ViewHolder();
      holder.name = v.findViewById(R.id.tv_name);
      v.setTag(holder);
    } else {
      holder = (ViewHolder) v.getTag();
    }
    holder.name.setText(
        mDataList.get(position).getGameName() + ":" + mDataList.get(position).getGameType()
            + mDataList.get(position).getGameNum() + "期");
    return v;
  }

  class ViewHolder {
    protected TextView name;
  }
}
